const imageBaseUrl = import.meta.env.VITE_BASE_URL + 'upload/'

export default {
  appkey: import.meta.env.VITE_APPKEY,
  USER: 'STUDY_USER',
  TOKEN: 'STUDY_TOKEN',
  EXPIRE: 'STUDY_EXPIRE',
  pageSize: import.meta.env.VITE_PAGE_LIMIT || 10,
  WhiteList: [
    'home',
    'login',
    'register',
    'error',
    'error_404',
    'error_500',
    'lesson',
    'lesson_detail'
  ],
  websocketUrl: import.meta.env.VITE_WS_URL + 'ws/study',
  imageUrl: (url: string) => {
    if (url !== '' && url.substring(0, 4) === 'http') {
      return url
    }
    return imageBaseUrl + url
  },
  videoUrl: (url: string) => {
    if (url !== '' && url.substring(0, 4) === 'http') {
      return url
    }
    return imageBaseUrl + url
  },
  fileUrl: (url: string) => {
    if (url !== '' && url.substring(0, 4) === 'http') {
      return url
    }
    return imageBaseUrl + url
  }
}
